Dialog Node
A node.js client for the Dialog API.
Examples
- Amazon Alexa (soon)
- Google Actions (soon)
- Twilio SMS (soon)
- Botpress
- Twilio Programmable Chat with Botkit
- Facebook Messenger with Botkit
- Facebook Messenger with Express
- Kik
Installation
Install using npm.
npm install dialog-api --save
Usage
This library needs to be configured with your API token which is available in your personal account, and a bot ID.
var Dialog = ;var dialog = request request;
Tracking messages
Generic
See docs.dialoganalytics.com/reference/track
var payload = message: platform: "messenger" provider: "dialog-node" mtype: "text" sent_at: 1484948110458 nlp: intents: name: 'rocket.launch' confidence: 098 properties: "text": "Launch some space rockets" conversation: distinct_id: "0a4b6c44-55e0-4381-a678-34f02b2620d7" creator: distinct_id: "d5ae3f5f-1645-40c3-a38a-02382cd0ee49" type: "interlocutor" username: "@elon" first_name: "Elon" last_name: "Musk" email: "elon@spacex.com" gender: "male" locale: "US" phone: "1234567890" profile_picture: "http://spacex.com/elon.jpg" timezone: -5 ; dialog;
Botpress
Example: Botpress bot with botpress-dialog
See botpress-dialog
Twilio Programmable Chat (IP Messaging) with Botkit
Example: Twilio Programmable Chat bot built with Botkit
var Dialog = ; controllermiddlewarereceive;controllermiddlewaresend;
Messenger with Botkit
Example: Messenger bot built with Botkit
var Dialog = ; controllermiddlewarereceive;controllermiddlewaresend;
Facebook Messenger with expressjs/express
Example: Messenger bot built with expressjs/express
var Dialog = ; var app = ; // ...app
Kik with @kikinteractive/kik
Example: Kik bot built with @kikinteractive/kik
var Dialog = // ...bot bot
Events
Send events to Dialog to keep track of your custom logic. Optionally pass an Interlocutor's distinct id to tie the event to one of your bot's interlocutors. See docs.dialoganalytics.com/reference/event#create
dialogevent'subscribed' 'interlocutorDistinctId' custom: 'value'
Clicks
Record clicks by interlocutors inside a conversation using a trackable link. For every links that needs to be tracked, generate a trackable URL by passing the interlocutor's distinct Id (provided by the platform or provider) and the url
to the link
method. See docs.dialoganalytics.com/reference/click-tracking
dialoglink'http://example.com' interlocutorDistinctId// https://api.dialoganalytics.com/v1/b/7928374/clicks/?id=123456&url=http%3A%2F%2Fexample.com
Attach
Modify the current track
payload about to be sent to Dialog's API with this helper method.
For example, you can specify a message name:
dialogdialog // equivalent
This will modify the track
payload:
message: name: "welcome" ... conversation: ... creator: ...
Messages
Retrieve a message
See docs.dialoganalytics.com/reference/message#retrieve
dialog
List all messages
List all messages in a conversation. See docs.dialoganalytics.com/reference/message#list
dialog
Conversations
Retrieve a conversation
See docs.dialoganalytics.com/reference/conversation#retrieve
dialog
List all conversations
See docs.dialoganalytics.com/reference/conversation#list
dialog
Interlocutors
List all interlocutors
See docs.dialoganalytics.com/reference/interlocutor#list
dialog
Retrieve an interlocutor
See docs.dialoganalytics.com/reference/interlocutor#retrieve
dialog
Update an interlocutor
See docs.dialoganalytics.com/reference/interlocutor#update
dialog
Creating an interlocutor
To create an interlocutor, use the track
endpoint. An interlocutor must initially be created in association with a conversation. See docs.dialoganalytics.com/reference/track
Documentation
See the API docs.