Build adapter¶
-
class
chatfirst.client.
Chatfirst
(token)¶ The Chatfirst class is a wrapper of Chatfirst API This class provides easy access to bots, push, talk, broadcast methods
Parameters: token (str) – user’s token from Chatfirst dashboard -
broadcast
(bot, channel_type, text)¶ Use this method to broadcast text message to all users of bot.
Parameters: - bot (Bot) – bot that will push user
- channel_type (str) – one of [telegram, facebook, slack]
- text (str) – text message
-
push
(bot, channel_type, ar, user_id)¶ Use this method to push message to user of bot. The message should be packed into ActionResponse object. This allows to push text messages, buttons, images. This also allows to force current state of user.
Parameters: - bot (Bot) – bot that will push user
- channel_type (str) – one of [telegram, facebook, slack]
- ar (ActionResponse) – message packed in response object
- user_id (str) – user id in used channel
-
-
class
chatfirst.models.
ActionResponse
(data={})¶ Main class defining ActionResponse entity
Parameters: data (dict) – serialized object -
count
= None¶ ignore this parameter
-
entities
= None¶ data[“Entities”], list of LinkedEntity objects
-
forced
= None¶ data[“ForcedState”], forced transition to state (useful trick for scoped scenarios and error handling)
-
keyboard
= None¶ data[“ForcedKeyboard”], keys to be shown to user
-
messages
= None¶ data[“Messages”], list of messages to return as text messages
-
to_json
()¶ Serialize object to json dict
Returns: dict
-
-
class
chatfirst.models.
LinkedEntity
(data={})¶ The way to show images in bot. Every object will be rendered as gallery or set of image messages.
Parameters: data (dict) – serialized object -
desc
= None¶ data[“Description”], description of image
-
name
= None¶ data[“Name”], name of image
-
options
= None¶ data[“EntityOptions”], keys to be shown to user
-
to_json
()¶ Serialize object to json dict
Returns: dict
-
url
= None¶ data[“ImageUrl”], url of image
-