MessageBird SDK: Template Messages/HSMs - whatsapp

I am trying to build a custom connector for the Rasa chatbot framework and MessageBird messaging service, specifically for Whatsapp Business channel. I have taken a look into Python SDK for MessageBird, and I don't see WhatsApp template messages (or Highly Structured Messages in MessageBird's definition) supported anywhere in it.
Am I mistaken? Or the current version of the MessageBird's SDK really supports only non-structured messages, regular SMS-es?
Thanks in advance for your help.

There is a MESSAGE_TYPE_HSM = "hsm" as a selectable type for a conversation message (defined here) and you will have to adapt the content to refer the appropriate HSM template id (see documentation):
"content":{
"hsm": {
"namespace": "5ba2d0b7_f2c6_433b_a66e_57b009ceb6ff",
"templateName": "order_update",
"language": {
"policy": "deterministic",
"code": "en"
},
"params": [
{"default": "Bob"},
{"default": "tomorrow!"}
]
}
Putting it all together, based on the example, it should look something like this:
msg = client.conversation_create_message(args['conversationId'],
{'channelId': args['channelId'], 'type': MESSAGE_TYPE_HSM,
"content":{"hsm": { "namespace": "5ba2d0b7_f2c6_433b_a66e_57b009ceb6ff","templateName": "order_update","language": {"policy": "deterministic","code": "en"},"params": [{"default": "Bob"},{"default": "tomorrow!"}]}}})
Where of course you will have to customize the content to your exact setup.

Related

Is ory/keto support Contextual and Time-based authorization?

I have a scenario where I want to restrict access to a document based on his IP address using ory/keto authorization service.
It looks like I can't achieve contextual attribute based authorization using ory/keto. I couldn't find any docs on that in ory/keto doc space. I tried few authorization check payloads to pass the dynamic attributes for the user. An example is provided below (I tried and it didn't work, ory/keto doesn't allow nested subject_sets).
{
"namespace": "document",
"object": "document",
"relation": "view",
"subject_set": {
"namespace": "user",
"object": "john",
"relation": "is",
"subject_set": {
"namespace": "ip-address-range",
"object": "0.0.0.10/11"
}
}
}
Can we achieve Contextual and Time-based authorization with ory/keto? If we can, can I get an example of how could I do it?
There is an issue for this (which was probably the inspiration for Auth0/OpenFGA): https://github.com/ory/keto/issues/319
It is a cool feature but there is no implementation effort yet.

Firebase Cloud Messaging Reports - not displaying sent count in Reports

We have set "analytics_label" in the message as stated in the documentation and the message is getting delivered as well. But we do not see any entry in the report. Please check our message string and let us know what might be wrong. Appreciate your help.
REST API being called
https://fcm.googleapis.com/fcm/send
Message being sent
{"topic":"81xxxxx42","android":{"priority":"high"},"priority":"high","fcm_options":{"analytics_label":"nwy81xxxxx42"},"data":{"MID":-1,"frm":"99xxxxx32","MTP":9,"msg":""}}
I'm not certain what library you're using or if you're just POSTing directly to the REST API, but looking at code that I know works I think you just need to make fcm_options and analytics_label camel case.
{
"topic": "81xxxxx42",
"android": {
"priority": "high"
},
"priority": "high",
"fcmOptions": {
"analyticsLabel": "nwy81xxxxx42"
},
"data": {
"MID": -1,
"frm": "99xxxxx32",
"MTP": 9,
"msg": ""
}
}

Spotify API: endpoint currently-playing podcast support

I'm developing a tool a tool (in Python 3) that gets my recently played track on Spotify. For that, I use the official Spotify API (you can try it there). When listening to music, I get a json containing the track, artist and much more info.
Unfortunately, this endpoint does not support listening to podcasts. When I listen to a podcast, the returned json is
{
"timestamp": 1545990763374,
"context": {
"external_urls": {
"spotify": "https://open.spotify.com/show/2tuQXnufTLetdGd7c24EfW"
},
"href": "https://api.spotify.com/v1/shows/2tuQXnufTLetdGd7c24EfW",
"type": "show",
"uri": "spotify:show:2tuQXnufTLetdGd7c24EfW"
},
"progress_ms": 11357,
"item": null,
"currently_playing_type": "episode",
"is_playing": true
}
which is not enough for my purposes. I googled a lot but did not find any endpoints of the Spotify API supporting podcasts.
Does anyone know a workaround?

Google Assistant - Account linking with Google Sign-In

I have an Express app which supports Google authentication and authorization via passport. I have begun integrating it with Google Assistant and things were going quite well but I am having trouble with the account linking as described at https://developers.google.com/actions/identity/google-sign-in#start_the_authentication_flow
Using the method in the docs at https://codelabs.developers.google.com/codelabs/actions-2/#4 I was able to get user details but when I try to modify to support
app.intent('Start Signin', conv => {
conv.ask(new SignIn('To get your account details'))
})
and
app.intent('Get Signin', (conv, params, signin) => { ...}
the dialogflow always falls back to my default fallback intent and I get an error in Express console
Error: Dialogflow IntentHandler not found for intent: Default Fallback Intent
My dialogflow intent is set to use webhook and other intents work fine (until I add these sign-in intents!)
Reading this thread Dialogflow IntentHandler not found for intent: myIntent (Dialogflow V2) it was suggested that the intent name rather than the action name is used so I check my Actions on Google simulator and the request contains:
"inputs": [
{
"intent": "actions.intent.SIGN_IN",
"rawInputs": [
{
"inputType": "KEYBOARD"
}
],
"arguments": [
{
"name": "SIGN_IN",
"extension": {
"#type": "type.googleapis.com/google.actions.v2.SignInValue",
"status": "OK"
}
}
]
}
],
so I tried updating my Dialogflow intent name to actions.intent.SIGN_IN and modifying the intent name in my Express app accordingly but it doesn't make any difference.
The simulator response includes:
"responseMetadata": {
"status": {
"code": 14,
"message": "Webhook error (206)"
},
but I'm not sure if that is just because for some reason the intent names are not matching up. Any help much appreciated!
As you speculate in the comments, the issue is that your "Get Signin" Intent isn't registered to get the event indicating that the user has signed in (or failed to). Since there is no such Intent setup, it ends up calling the Fallback Intent, which apparently doesn't have an Intent Handler registered in your webhook.
To make your "Get Signin" Intent get the sign-in event, set the "Event" field to actions_intent_SIGN_IN. (Note the similarity to the Intent name you saw in the simulator, but using underscores instead of dots.)
As an aside, the simulator was showing you what the communication between the Assistant and Dialogflow looks like, so it can be somewhat confusing to understand what Dialogflow is doing with it. It didn't have anything to do with the name of your Intent or anything else.
Finally, it often isn't necessary to do this check. You will know if the user is signed in because either the auth token has been set or the id token has been set (depending on your method of Account Linking).

Storing branch attributes offline from Branch.io to track user attribution in my own database

I am trying to store our a campaign attribution identifier offline so that we can do some very custom analytics on the response. Our business team has very specific criteria for determining repeat user activities in our system that can't be tracked with normal analytics, at least not in a very simple way. They need to know how individual users were referred to our system via campaigns, links, etc.
I believe this is as simple as using branch.io to generate a link with specific data in that link. Then, assuming that user ever clicked that link, we should be able to, from our app, use the branch.io SDK to call out to branch.io, retrieve the attribution information, and then pass it to our own servers.
Is this use case possible with branch.io, and am I thinking of it correctly?
Create a branch.io link with a unique referral source
User clicks on that link which may or may not take them to an install
Eventually the user installs our app
On registration within our app we query branch.io using the SDK and ask it for existing attribution information associated to that user.
We make an API call to our own services and pass down whatever we got from branch.io and the user's ID to persist in our own analytics database.
Please let me know if this is possible and if we're thinking of it correctly. I believe this is fundamentally the same use case as custom on-boarding but need to verify for our management team before we bother to implement.
The client-to-server technique that you have described in your response will absolutely work with Branch! If you are interested in a server-to-server approach, your best bet would be to create a webhook from your Dashboard account for the Install event. When installs are referred you'll notice that the json data included in the response will have:
{
"metadata": {
"ip": "<purposely stripped out>",
"referred": true
},
"os": "iOS",
"session_referring_click_timestamp": "2016-02-09T15:57:23.411Z",
"session_referring_click_query": {},
"os_version": "9.2.1",
"first_referring_click_timestamp": "2016-02-09T15:57:23.411Z",
"first_referring_link_data": {
"date_ms": 1455033416690,
"date_sec": 1455033416,
"date": "2016-02-09T15:56:56.690Z",
"data": {
"$og_title": "Jingles Bingleheimer",
"$publicly_indexable": 1,
"face_index": "2",
"~creation_source": 3,
"$identity_id": "225633246304569572",
"monster": "true",
"+url": "https://bnc.lt/ALMc/pkZbNmazPq",
"$one_time_use": false,
"~id": "225633381004658863",
"~channel": "sms",
"body_index": "1",
"monster_name": "Matts Monster",
"$exp_date": 0,
"color_index": "4"
},
"branch_id": "225633381004658863",
"app_short_identifier": "625048",
"domain": "bnc.lt",
"channel": "sms",
"state": 1,
"href": "/ALMc/pkZbNmazPq"
},
"first_referring_click_query": {},
"event": "install",
"event_timestamp": "2016-02-09T15:57:51.019Z",
"session_referring_link_data": {
"date_ms": 1455033416690,
"date_sec": 1455033416,
"date": "2016-02-09T15:56:56.690Z",
"data": {
"$og_title": "Jingles Bingleheimer",
"$publicly_indexable": 1,
"face_index": "2",
"~creation_source": 3,
"$identity_id": "225633246304569572",
"monster": "true",
"+url": "https://bnc.lt/ALMc/pkZbNmazPq",
"$one_time_use": false,
"~id": "225633381004658863",
"~channel": "sms",
"body_index": "1",
"monster_name": "Matts Monster",
"$exp_date": 0,
"color_index": "4"
},
"branch_id": "225633381004658863",
"app_short_identifier": "625048",
"domain": "bnc.lt",
"channel": "sms",
"state": 1,
"href": "/ALMc/pkZbNmazPq"
},
"hardware_id": "<purposely stripped out>"
}
As you can see, it will include the referring link information in the response.
In general, installs will be referred if:
The user clicks on a Branch link and there is an identity associated to the link.
The user installing the app has not installed the app in the past.
Also, webhook documentation can be found here and the SDK will need to be integrated with your app so that Branch can understand that an Install event has occurred.
Note: You can also create webhooks on custom events such as "sign_up_complete" as well.