Instagram API

What is a persistent menu

A persistent menu allows you to create and send a menu of your business’s main functions, such as business hours, store locations, and products. It will always be visible during a person’s conversation with your company in Messenger.

Supported buttons:

The persistent menu consists of a set of buttons. The following types of buttons are supported in the persistent menu:

● URL buttons (web_url) ● Callback buttons (postback)

How to add a persistent menu

response = ig_set_persistent_menu(login, buttons), where: login - your Instagram login (can be found in the "Channel" MaviBot menu) buttons - a dictionary containing buttons

Example of how to structure the button dictionary: buttons = {"default": [["postback", "Button 1", "callback_text 1"], ["postback", "Button 2", "callback_text 2"], ["web_url", "Site link", "https://mavibot.ai/"]]} default - a required key that defines the array of buttons to be shown in the menu by default, regardless of the user's localization. The value should be an array of buttons. Each button is described as a separate array in the following format:

["button_type", "Button display text", "Callback text sent to the bot"]

Button types and their description: - callback button: ["postback", "Button display text", "Callback text sent to the bot"] - URL button: ["web_url", "Link display text", "https://example.com"]

How to configure the menu based on user localization

You can set up buttons for different regions by adding additional keys to the button dictionary corresponding to specific locales.

For example, to add buttons for English locale:

buttons = {"default": [["postback", "Button 1", "callback_text 1"], ["postback", "Button 2", "callback_text 2"], ["web_url", "Site link", "https://mavibot.ai/"]], "en_EN": [["postback", "Button", "callback_text 1"], ["postback", "Button 2", "callback_text 2"], ["web_url", "Link", "https://mavibot.ai/"]]}

Note: In this case, the key represents the locale for which the buttons will be displayed.

Supported locales: af_ZA, ar_AR, as_IN, az_AZ, be_BY, bg_BG, bn_IN, br_FR, bs_BA, ca_ES, cb_IQ, co_FR, cs_CZ, cx_PH, cy_GB, da_DK, de_DE, el_GR, en_GB, en_UD, en_US, es_ES, es_LA, et_EE, eu_ES, fa_IR, ff_NG, fi_FI, fo_FO, fr_CA, fr_FR, fy_NL, ga_IE, gl_ES, gn_PY, gu_IN, ha_NG, he_IL, hi_IN, hr_HR, hu_HU, hy_AM, id_ID, is_IS, it_IT, ja_JP, ja_KS, jv_ID, ka_GE, kk_KZ, km_KH, kn_IN, ko_KR, ku_TR, lt_LT, lv_LV, mg_MG, mk_MK, ml_IN, mn_MN, mr_IN, ms_MY, mt_MT, my_MM, nb_NO, ne_NP, nl_BE, nl_NL, nn_NO, or_IN, pa_IN, pl_PL, ps_AF, pt_BR, pt_PT, qz_MM, ro_RO, ru_RU, rw_RW, sc_IT, si_LK, sk_SK, sl_SI, so_SO, sq_AL, sr_RS, sv_SE, sw_KE, sz_PL, ta_IN, te_IN, tg_TJ, th_TH, tl_PH, tr_TR, tz_MA, uk_UA, ur_PK, uz_UZ, vi_VN, zh_CN, zh_HK, zh_TW

Example of a request:

In case of successful execution, the function returns: {"result":"success"}

Otherwise, an error description is returned:

"Error parse buttons data" indicates an error in the buttons dictionary. {"error":{"message":"(#100) param persistent_menu[0][call_to_actions] must be non-empty.","type":"OAuthException","code":100,"fbtrace_id":"AJtVczu7TEJJxbMfnO"}}

How to delete a permanent menu

response = ig_delete_persistent_menu('login'), where login - account name

In case of successful execution, the function returns:

{"result":"success"}

Otherwise, an error description is returned:

"Bot not found"

Last updated