python-smooch

Python wrapper for the Smooch API.

Installation

$ pip install python-smooch

Usage

Before using python-smooch you have to export your SMOOCH_KEY_ID and SMOOCH_SECRET to your local environment.

export SMOOCH_KEY_ID="your_key_id"
export SMOOCH_SECRET="your_secret"

You can then import python-smooch with the following:

import smooch

API

This is a listing of the methods provided by python-smooch and the arguments they take. I've only gone into detail in places where I made representational choices. So you don't have to go through the code. The definitive API Docs are from Smooch.

Messages

FunctionArgumentsNotes
send_messageuser_id:string, plain_text:string, sent_by_maker=true
get_conversationuser_id:string
send_linksuser_id:string, message_text:string, options:[(tag, uri)]
send_postbacksuser_id:string, message_text:string, options:[(tag, postback payload)]
request_paymentuser_id:string, message_text:string, options:[(tag, price in cents)]Note stripe must be enabled.
send_buttonsuser_id:string, message_text:string, options:[(message_text, kind, result)]This allows you to mix button types in the same message.

Users

FunctionArgumentsNotes
pre_create_useruser_id:string
get_useruser_id:string
update_useruser_id:string, data:map
init_userdevice:string, user_id:string=None

Webhooks

FunctionArgumentsNotes
get_webhookwebhook_id:string
create_webhooktarget:uri, triggers:[string]trigger types are defined by smooch.
list_webhooks
ensure_webhook_existtarget:uri, triggers:[string]trigger types are defined by smooch.
delete_webhookwebhook_id:string
delete_all_webhooks
update_webhookwebhook_id:string, target:uri, triggers:[string]