https://github.com/emorissettegregoire/stealth-messagebird
MessageBird Whatsapp driver for Stealth
https://github.com/emorissettegregoire/stealth-messagebird
chatbot messagebird omnichannel stealth whatsapp-bot
Last synced: 2 months ago
JSON representation
MessageBird Whatsapp driver for Stealth
- Host: GitHub
- URL: https://github.com/emorissettegregoire/stealth-messagebird
- Owner: emorissettegregoire
- License: mit
- Created: 2020-06-11T11:52:11.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T09:55:49.000Z (over 2 years ago)
- Last Synced: 2024-10-19T02:15:12.371Z (8 months ago)
- Topics: chatbot, messagebird, omnichannel, stealth, whatsapp-bot
- Language: Ruby
- Homepage:
- Size: 45.9 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Messagebird WhatsApp Driver for Stealth
The [Stealth](https://github.com/hellostealth/stealth) WhatsApp driver adds the ability to build your bot using [Messagebird](https://www.messagebird.com/en/solutions/whatsapp-api) service.
Messagebird allow you to use your [own mobile number](https://support.messagebird.com/hc/en-us/articles/360000244558-How-to-pick-a-number-for-WhatsApp-Business) for WhatsApp. So no geographic restrictions compare to virtual mobile numbers (VMNs).
In `Gemfile`
```
gem 'stealth-messagebird'
```Then create a Messagebird account and install your [WhatsApp Business channel](https://support.messagebird.com/hc/en-us/articles/360000258437-WhatsApp-Business-step-by-step-onboarding). This gem is not supporting the Messagebird Sandbox, since their Sandbox has limitations.
## WhatsApp Supported Reply Types
* Text
* Image
* Audio
* Video/GIF (receive only)
* File
* Sticker
In your Stealth bot replies
```
- reply_type: sticker
sticker_url: "https://your-sticker.webp"
```* Delay
* Location
In your Stealth bot replies
```
- reply_type: location
latitude: 41.69352000000001
longitude: 44.801473999999985
```* Quick Reply (max 3 buttons)
In your Stealth bot replies
```
- reply_type: quick_reply
header_type: "image"
header_url: "https://image.png"
text: "Your text"
buttons:
- title: "button 1"
payload: "button-1"
- title: "button 2"
payload: "button-2"
- title: "button 3"
payload: "button-3"- reply_type: quick_reply
header_type: "text"
header_text: "Awesome text"
text: "More descriptive text"
buttons:
- title: "button 1"
payload: "button-1"
- title: "button 2"
payload: "button-2"
- title: "button 3"
payload: "button-3"
````header_type` can be an "image", "video", "document" or "text".
User's input can be retrieved in `current_message.payload`* List message (max 10 buttons)
In your Stealth bot replies
```
- reply_type: list
title: "What would you like to buy today?"
text: "To begin, tap Main Menu and choose from one of the following options."
button: "Main Menu"
sections:
- title: "Bundles"
buttons:
- title: "Buy bundle 1"
payload: "bundle-1"
- title: "Buy bundle 2"
payload: "bundle-2"
- title: "Airtime"
buttons:
- title: "Buy Airtime"
payload: "airtime-1"
description: "optional description"
```
User's input can be retrieved in `current_message.payload`More info here: https://developers.messagebird.com/quickstarts/whatsapp-deepdive/
## Configure Messagebird with your Stealth bot
Once your WhatsApp Business Channel is active, you will receive a `channel_id`.
To visualize your channel_id, go to `Channels` in the sidebar of your Messagebird Dashboard.
You will need your Live API Key as well, go to `Developers` in the sidebar of your Messagebird Dashboard.In `services.yml`
```
messagebird:
access_key: <%= ENV['MESSAGEBIRD_ACCESS_KEY'] %>
channel_id: <%= ENV['MESSAGEBIRD_CHANNEL_ID'] %>
```## Setup your Webhook
Create your webhook so that Messagebird can communicate with your app when receiving a message from a user.
Subscribe to `message.created` event only.```
curl -X POST "https://conversations.messagebird.com/v1/webhooks/" \
-H "Authorization: AccessKey YOUR_ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{
"events": ["message.created"],
"channelId": "YOUR_CHANNEL_ID",
"url": "https://1cfd8wc098r0.ngrok.io/incoming/messagebird"
}'
```
When you provide your local ngrok URL to a messaging service, you will have to add /incoming/messagebird. More infos on [Stealth Repo](https://github.com/hellostealth/stealth/wiki/Local-Development).For more infos on webhooks, follow the [Messagebird instructions](https://developers.messagebird.com/api/conversations/#create-webhook).
## current_message
When calling the `current_message` method in your Stealth bot, you can retrieve the following informations:
```
#
```